package org.giovanolli.mumi.controller.business;

import org.giovanolli.mumi.controller.AbstractController;
import org.giovanolli.mumi.controller.AbstractModel;
import org.giovanolli.mumi.entities.AttentionType;
import org.giovanolli.mumi.entities.filter.AttentionTypeFilter;
import org.giovanolli.mumi.service.AttentionTypeService;
import org.giovanolli.mumi.service.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller("attentionTypeController")
public class AttentionTypeController extends AbstractController<AttentionType> {

	@Autowired
	private AttentionTypeService service;

	@Autowired
	private AttentionTypeModel model;

	public void init() {
		super.init();
		model.setFilter(new AttentionTypeFilter());
	}

	@Override
	protected void bindModelToEntity() {
		AttentionType editedAttentionType = model.getEditedEntity();
		editedAttentionType.setName(model.getName());
		editedAttentionType.setDescription(model.getDescription());
	}

	@Override
	protected void bindEntityToModel() {
		AttentionType editedAttentionType = model.getEditedEntity();
		model.setName(editedAttentionType.getName());
		model.setDescription(editedAttentionType.getDescription());
	}

	@Override
	protected AbstractModel<AttentionType> getModel() {
		return model;

	}

	@Override
	protected Service<AttentionType> getService() {
		return service;
	}

	protected Class<AttentionType> getEntityClass() {
		return AttentionType.class;
	}
}
